//    Copyright (C) Kherty.  All rights reserved.
using System;

namespace OpenLS.Spreadsheet.Extensibility
{
    public class AccessCellValueAttribute : Attribute, IParameterConverter, IParameterConverterProvider
    {

        #region IArgumentConverterProvider Members

        public IParameterConverter GetConverter()
        {
            return this;
        }

        #endregion

        #region IArgumentConverter Members

        public void Convert(ConversionData data)
        {
            if (data.Value is ICell)
            {
                data.Dereference();
            }
            if (data.Value != null && data.TargetType.IsAssignableFrom(data.Value.GetType()))
            {
                data.Result = data.Value;
            }
            if (data.Value == null && AcceptNull)
            {
                data.Result = data.Value;
            }
        }

        public int Priority
        {
            get { return 10; }
        }

        private bool force;

        public bool Force
        {
            get { return force; }
            set { force = value; }
        }
        private bool _acceptNull;

        public bool AcceptNull
        {
            get { return _acceptNull; }
            set { _acceptNull = value; }
        }
	


        #endregion
    }
}